package com.cskaoyan.crud;

import com.cskaoyan.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/07/26 11:24
 *
 * @author ciggar
 */
public class StatementDemo {


    public static void main(String[] args) throws SQLException {

        // 获取连接对象
        Connection connection = JDBCUtils.getConnection();

        // 获取Statement对象
        Statement statement = connection.createStatement();

        boolean ret = statement.execute("select * from city");

        System.out.println(ret);


        // 获取结果集
        ResultSet resultSet = statement.getResultSet();

        while (resultSet.next()) {
            String name = resultSet.getString("name");

            System.out.println("name:" + name);
        }

        JDBCUtils.closeResource(statement,connection);
    }
}
